#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include    <QHostAddress>
#include    <QHostInfo>
#include    <QTcpSocket>
#include    <QLabel>


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    //自定义槽函数
        void    onConnected();
        void    onDisconnected();
        void    onSocketStateChange(QAbstractSocket::SocketState socketState);
        void    onSocketReadyRead();//读取socket传入的数据

    void on_actConnection_triggered();

    void on_actDisconnect_triggered();

    void on_actClear_triggered();

    void on_btnSend_clicked();

private:
    Ui::MainWindow *ui;

    QTcpSocket  *tcpClient;  //socket
    QLabel  *LabSocketState;  //状态栏显示标签
    QString getLocalIP();//获取本机IP地址

protected:
    void    closeEvent(QCloseEvent *event);
};

#endif // MAINWINDOW_H
